<?php
/**
 * Created by PhpStorm.
 * User: beich
 * Date: 2019/1/29
 * Time: 13:04
 */
include_once 'c.php';
$page = $_GET['page'];
$num = Response::getData("select count(1) as count from `doc_document` ", $con)->count;
$allpage = ceil($num / 16);
if (empty($_GET['page']) || $page < 1) {
    $page = 1;
}
if ($page > $allpage) {
    $page = $allpage;
}
$tpage = $page - 1;
$Datas = Response::getDatas("SELECT id,title,user,updatetime,img FROM  `doc_document` LIMIT {$tpage} , 16", $con);

?>
<!doctype html>
<html class="no-js" lang="zxx">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Karigor - Portfolio Bootstrap4 Template</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Favicon -->
    <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon">
    <link rel="apple-touch-icon" href="img/icon.png">

    <!-- Google font (font-family: 'Dosis', sans-serif;) -->
    <link href="https://fonts.googleapis.com/css?family=Dosis:300,400,500,600,700" rel="stylesheet">

    <!-- Plugins -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/plugins.css">

    <!-- Style Css -->
    <link rel="stylesheet" href="css/style.css">

    <!-- Custom Styles -->
    <link rel="stylesheet" href="css/custom.css">
</head>

<body>

<!-- Wrapper -->
<div id="wrapper" class="wrapper">

    <!-- Header -->
    <header class="header sticky-header">
        <div class="container">
            <div class="header-inner d-none d-lg-flex">
                <div class="header-logo">
                    <a href="index.html">
                        <img src="img/logo/logo-dark.png" alt="logo">
                    </a>
                </div>
                <div class="header-navigation">
                    <button class="header-navigation-trigger">
                        <span></span>
                        <span></span>
                        <span></span>
                    </button>
                    <nav class="main-navigation">
                        <?= Response::ulLis($con) ?>
                    </nav>
                </div>
            </div>
            <div class="mobile-menu-wrapper d-block d-lg-none">
                <div class="mobile-menu clearfix">
                    <a href="index.html" class="mobile-logo">
                        <img src="img/logo/logo-dark.png" alt="mobile logo">
                    </a>
                </div>
            </div>
        </div>
    </header>
    <!--// Header -->

    <!-- Breadcrumb Area -->
    <div class="breadcrumb-area bg-grey">
        <div class="container">
            <div class="cr-breadcrumb">
                <h2>DOCUMENT</h2>
                <ul>
                    <li><a href="index.html">Home</a></li>
                    <li>DOCUMENT</li>
                    <li><?=$page?></li>
                </ul>
            </div>
        </div>
    </div>
    <!--// Breadcrumb Area -->

    <!-- Page Conttent -->
    <main class="page-content">

        <!-- Blog Area -->
        <div class="cr-section blog-area section-padding-lg">
            <?php
            if (count($Datas) == 0) {
                ?>
                <div class="container doc_body_loading">
                    <div class="row justify-content-center">
                        <div class="col-xl-12 col-lg-12 col-md-12 col-12" style="text-align: center">
                            <img src="img/loading.gif" alt="">
                        </div>
                    </div>
                </div>
                <?php
            } else {
                ?>
                <div class="container doc_body">
                    <div class="row justify-content-center">
                        <!-- sticky-->
                        <?php
                        foreach ($Datas as $data) {
                            echo '<div class="col-xl-3 col-lg-6 col-md-6 col-12">
                        <article class="blog-item ">
                            <header class="blog-item-header">
                                <a href="details-'.$data->id.'.html">
                                    <img src="update/' . $data->img . '" alt="blog thumb">
                                </a>
                            </header>
                            <div class="blog-item-body">
                                <h6 class="blog-item-title">
                                <a href="details-'.$data->id.'.html">' . $data->title . '</a></h6>
                            </div>
                            <footer class="blog-item-footer">
                                <ul class="blog-item-meta">
                                    <li><i class="fa fa-user-o"></i>By <a href="blog.html">' . $data->user . '</a></li>
                                    <li class="float-lg-right"><i class="fa fa-calendar-o"></i>' . $data->updatetime . '</li>
                                </ul>
                            </footer>
                        </article>
                    </div>';
                        }
                        ?>

                        <!--<div class="col-xl-3 col-lg-6 col-md-6 col-12">-->
                        <!--<article class="blog-item sticky">-->
                        <!--<header class="blog-item-header">-->
                        <!--<a href="details.html">-->
                        <!--<img src="img/update/python_hxbc.jpg" alt="blog thumb">-->
                        <!--</a>-->
                        <!--</header>-->
                        <!--<div class="blog-item-body">-->
                        <!--<h6 class="blog-item-title"><a href="details.html">Accusamus iste quia qui quisquam-->
                        <!--qui</a></h6>-->
                        <!--</div>-->
                        <!--<footer class="blog-item-footer">-->
                        <!--<ul class="blog-item-meta">-->
                        <!--<li><i class="fa fa-user-o"></i>By <a href="blog.html">Admin</a></li>-->
                        <!--<li><i class="fa fa-calendar-o"></i> 30 Nov 2018</li>-->
                        <!--</ul>-->
                        <!--</footer>-->
                        <!--</article>-->
                        <!--</div>-->


                    </div>
                    <div class="cr-pagination mt-4 text-center">
                        <ul>
                            <li><a href="blog.html"><i class="fa fa-angle-double-left"></i></a></li>
                            <li><a href="blog.html">1</a></li>
                            <li><a href="blog.html">2</a></li>
                            <li><a href="blog.html">3</a></li>
                            <li><a href="blog.html">...</a></li>
                            <li><a href="blog.html">10</a></li>
                            <li><a href="blog.html"><i class="fa fa-angle-double-right"></i></a></li>
                        </ul>
                    </div>
                </div>
                <?php
            }
            ?>
        </div>
        <!--// Blog Area -->

    </main>
    <!--// Page Conttent -->
    <?= Response::$footer ?>

</div>
<!--// Wrapper -->

<!-- Js Files -->
<script src="js/vendor/modernizr-3.6.0.min.js"></script>
<script src="js/vendor/jquery-3.3.1.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>

</body>
</html>
